function setMap(datas) {
	var centerLat = Number(datas[0].lat);
	var centerLng = Number(datas[0].lon);
	var centerLatlng = new google.maps.LatLng(centerLat, centerLng);
	var myOptions = {
	  zoom: 22,
	  center: centerLatlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	for (var i = 0; i < datas.length; i++) {
		var data = datas[i];
		var lat = Number(data.lat);
		var lng = Number(data.lon);
		var latlng = new google.maps.LatLng(lat,lng);
	
		var marker = new google.maps.Marker({
			position: latlng, 
			map: map,
			title:"測定値:" + data.count + " 日時:" + data.created_at
		});
	}
}

$(document).ready(function(){
	$("#link-map").bind("click", function() {
		//var URL = "http://twitter.com/statuses/user_timeline/imaocande.json?count=40&callback=?";
		var URL = "http://twitter.com/statuses/user_timeline/imaocandeforest.json?count=40&callback=?";
		function getTweet(callback) {
			$.getJSON(URL, function(results) {
				//var latlngs = [];
				var datas = [];
				$.each(results, function(i, message) {
					try {
						//var d = parseXML(unescapeHTML(message.text));
						var d = jQuery.parseJSON(message.text);
						d.created_at = dateToString(new Date(message.created_at));
						datas.push(d);
					} catch ( e ) {
						// エラーは無視。。
					}
				});
			
				setMap(datas);
			
				if ( callback ) {
					callback();
				}
			});
		}

		$("#refresh-map").bind("click", function() {
			$.mobile.pageLoading();
			getTweet(function() {
				$.mobile.pageLoading(true);
			});
		});

		getTweet();
		
	});
});

